#include <iostream>
#include <string>
#include "D:\MyCode\cpp-basic-practice\StrVec\StrVec.h"

int main() {
    // 测试使用初始化列表构造函数
    StrVec vec1{"apple", "banana", "cherry"};
    std::cout << "vec1 size: " << vec1.size() << ", capacity: " << vec1.capacity() << std::endl;
    for (auto it = vec1.begin(); it != vec1.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    // 测试拷贝构造函数
    StrVec vec2(vec1);
    std::cout << "vec2 size: " << vec2.size() << ", capacity: " << vec2.capacity() << std::endl;
    for (auto it = vec2.begin(); it != vec2.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    // 测试拷贝赋值运算符
    StrVec vec3;
    vec3 = vec1;
    std::cout << "vec3 size: " << vec3.size() << ", capacity: " << vec3.capacity() << std::endl;
    for (auto it = vec3.begin(); it != vec3.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    // 测试 push_back 方法
    vec1.push_back("date");
    std::cout << "After push_back 'date', vec1 size: " << vec1.size() << ", capacity: " << vec1.capacity() << std::endl;
    for (auto it = vec1.begin(); it != vec1.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    // 测试 reserve 方法
    vec1.reserve(10);
    std::cout << "After reserve(10), vec1 size: " << vec1.size() << ", capacity: " << vec1.capacity() << std::endl;

    // 测试 resize 方法
    vec1.resize(5, "elderberry");
    std::cout << "After resize(5, 'elderberry'), vec1 size: " << vec1.size() << ", capacity: " << vec1.capacity() << std::endl;
    for (auto it = vec1.begin(); it != vec1.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    vec1.resize(2);
    std::cout << "After resize(2), vec1 size: " << vec1.size() << ", capacity: " << vec1.capacity() << std::endl;
    for (auto it = vec1.begin(); it != vec1.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;

    return 0;
}
